Skip to main content

Case Transformation Functions

These are the main functions used in the token processing loop for converting between naming conventions while respecting language keywords.

to= "s"

for _, line := range lines {
tokens := cc_lib.Tokenize(line)

for _, tok := range tokens {

switch from {
case 's':
cc_lib.FromSnake(tok, to, selectedLanguage)
case 'c':
cc_lib.FromCamel(tok, to, selectedLanguage)
case 'p':
cc_lib.FromPascal(tok, to, selectedLanguage)
default:
fmt.Println("Specify correct input output directives")
fmt.Println(help_directives)
os.Exit(1)
}

}

}
FunctionDescription
FromSnakeConverts a snake_case token to a target case: camelCase ('c') or PascalCase ('p'). If the token is a keyword in the selected Language, it is printed unchanged.
FromCamelConverts a camelCase token to a target case: snake_case ('s') or PascalCase ('p'). Keywords are preserved.
FromPascalConverts a PascalCase token to a target case: camelCase ('c') or snake_case ('s'). Keywords are preserved.

Parameters (for FromSnake, FromCamel, FromPascal)

NameTypeDescription
tokenstringThe token to be transformed from its current case.
outputbyteDirective specifying the target case: 'c' for camelCase, 'p' for PascalCase, 's' for snake_case.
lang*LanguagePointer to a Language struct. If the token is a keyword in this language, it is printed unchanged.